
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/commonly-used-show.css" />
    <script type="text/javascript" src="approvalProcess/js/jquery.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap.js" ></script>
    <script type="text/javascript" src="approvalProcess/js/jquery.cookie.js"></script>

    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap-datetimepicker.min.css" />
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>


    <title>审批详情</title>

</head>
<body class="mybody">

 <jsp:include page="theTopMenuDoorkeeper.jsp" />



 <div class="container-fluid">
    <div class="row">


        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div id="applicat_modality" class="alert alert-success">


                                <div class="container">
        <h3 style="text-align: center">申请信息</h3>
        <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

        <div id="add_apply" class="container">
            <div class="form-group same-line">
                <label><b style="color: red">*&nbsp</b>学院：</label>
                <input type="text" id="name_college" class="form-control edit" placeholder="请输入学院">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>职工号：</label>
                <input type="text" id="student_number" class="form-control edit" placeholder="请输入学号" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="15">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>姓名：</label>
                <input type="text" id="user_name" class="form-control edit" placeholder="请输入姓名" maxlength="6">
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>用户性别：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="user_sex" data-live-search="true" >
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>


            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>本人联系方式：</label>
                <input type="text" id="user_tel" class="form-control edit" placeholder="请输入本人联系方式" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>出校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="start_time">
                    <input id="start_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden" />
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>返校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="end_time">
                    <input id="end_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden" />
            </div>

            <div class="form-group same-line-left">
                <label >出行方式：</label>
                <input type="text" id="trip_mode" class="form-control edit" placeholder="公交车/出租车/步行/地铁" maxlength="20" >
            </div>

            <div class="form-group same-line-left">
                <label >目的地：</label>
                <input type="text" id="destination" class="form-control edit" placeholder="请输入目的地" maxlength="20">
            </div>

            <div class="form-group same-line">
                 <label ><b style="color: red">*&nbsp</b>申请出校原因：</label>
                <textarea id="reasons_school" style="width:500px; height:124px; resize: none;" placeholder="请在此填写出校原因" class="form-control edit" rows="3" cols="50"></textarea>
            </div>

            <div class="form-group same-line-left">
                <label >出行路线：</label>
                <input type="text" id="travel_route" style="width: 500px" class="form-control edit" placeholder="请输入出行路线" maxlength="40">
            </div>


        </div>

</div>

                            </div>





                            <div id="applicat_modalitythree" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">院领导审核建议</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">
                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>院领导姓名：</label>
                                            <input type="text" id="leaders_name" class="form-control edit" placeholder="请输入院领导姓名" maxlength="6">
                                    </div>

                                        <div class="form-group same-line-left">
                                        <label ><b style="color: red">*&nbsp</b>院审批结果：</label>
                                        <select style="font-size:14px" class="form-control edit" title="请选择" id="leaders_agree_state" data-live-search="true" >
                                            <option value="" disabled selected hidden>请选择</option>
                                            <option value="同意">同意</option>
                                            <option value="不同意">不同意</option>
                                        </select>
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label >院审批意见：</label>
                                        <textarea id="leaders_audit_recommen" style=" height:124px; resize: none;" placeholder="请在此填写审批建议" class="form-control edit" rows="3" cols="50"></textarea>
                                    </div>

                                    </div>


                                </div>

                            </div>

                            <div id="applicat_modalityfoure" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">校领导审核建议</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">
                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>校领导姓名：</label>
                                            <input type="text" id="school_name" class="form-control edit" placeholder="请输入校领导姓名" maxlength="6">
                                    </div>

                                        <div class="form-group same-line-left">
                                        <label ><b style="color: red">*&nbsp</b>校审批结果：</label>
                                        <select style="font-size:14px" class="form-control edit" title="请选择" id="school_agree_state" data-live-search="true" >
                                            <option value="" disabled selected hidden>请选择</option>
                                            <option value="同意">同意</option>
                                            <option value="不同意">不同意</option>
                                        </select>
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label >校审批意见：</label>
                                        <textarea id="school_audit_recommen" style=" height:124px; resize: none;" placeholder="请在此填写审批建议" class="form-control edit" rows="3" cols="50"></textarea>
                                    </div>

                                    </div>


                                </div>

                            </div>

                            <div id="applicat_modalityfive" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">出入时间记录</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">

                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>出校时间：</label>
                                            <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="out_time">
                                                <input id="out_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                                                <span class="add-on"><i class="icon-remove"></i></span>
                                                <span class="add-on"><i class="icon-th"></i></span>
                                            </div>
                                            <input class="form-control edit" type="hidden" />
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label ><b style="color: red">*&nbsp</b>入校时间：</label>
                                        <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="enrolled_time">
                                            <input id="enrolled_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                                            <span class="add-on"><i class="icon-remove"></i></span>
                                            <span class="add-on"><i class="icon-th"></i></span>
                                        </div>
                                        <input class="form-control edit" type="hidden" />
                                    </div>

                                        <div class="form-group same-line-left">
                                            <label ><b style="color: red">*&nbsp</b>入校体温：</label>
                                            <input type="text" id="enrolled_animal" class="form-control edit" placeholder="请输入入校体温" maxlength="6">
                                    </div>

                                    </div>


                                </div>

                            </div>


                            <div class="container">

                                <div style="margin-top: 50px; margin-bottom: 50px;" class="form-group text-center same-line-clear">
                                        <input id="operation_status" type="button" value="确认提交" class="btn btn-primary">
                                    </div>

                                    <div class="text-center">
                                        <div style="margin-top: 20px;">
                                            <span id="user_messge" style="font-size:18px; color: red;"></span>
                                        </div>
                                    </div>

                                </div>





                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>


<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }


    window.onload = function(){
        queryApplyInfo();
        college();
        modality2();
        queryInOutTimeInfo();
    }


    function modality2(){
        $("#applicat_modality").addClass("alert alert-success");
        $("#applicat_modalitytwo").addClass("alert alert-success");
        $("#applicat_modalitythree").addClass("alert alert-success");
        $("#applicat_modalityfoure").addClass("alert alert-success");
        $("#applicat_modalityfive").addClass("alert alert-success");
    }


    function college(){
        notEditable();
        $("#leaders_name").attr("readOnly",true);
        $("#leaders_agree_state").attr("disabled",true);
        $("#leaders_audit_recommen").attr("readOnly",true);

        $("#school_name").attr("readOnly",true);
        $("#school_agree_state").attr("disabled",true);
        $("#school_audit_recommen").attr("readOnly",true);
    }



    function addInOutTime(){
        var mOutTime = $("#out_time").val();

        if ($.isEmptyObject(mOutTime)){
            $("#user_messge").text("出校时间不能为空");
            return false;
        }else {
            $("#user_messge").text("");
        }

        var postUrl = "${pageContext.request.contextPath}/addMyApproval";
        var str = {
            "id": "${param.id}",
            "userLevel": userdt.result.userLevel,
            "approvalNoteId": userdt.result.id,
            "approvalStatus": "6",
            "nameApproval": mOutTime
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#user_messge").text(data.msg);
                }else {
                    location.href = "${pageContext.request.contextPath}/myDoorkeeperApplication?type=4";
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

    function updateInOutTime(){

        var mEnrolledime = $("#enrolled_time").val();
        var mEnrolledAnimal = $("#enrolled_animal").val();

        if ($.isEmptyObject(mEnrolledime)){
            $("#user_messge").text("入校时间不能为空");
            return false;
        }else if ($.isEmptyObject(mEnrolledAnimal)){
            $("#user_messge").text("入校体温不能为空");
            return false;
        }else {
            $("#user_messge").text("");
        }

        var postUrl = "${pageContext.request.contextPath}/updateMyApproval";
        var str = {
            "id": "${param.id}",
            "userLevel": userdt.result.userLevel,
            "approvalNoteId": userdt.result.id,
            "approvalStatus": "6",
            "approvalResult": mEnrolledime,
            "approvalAdvice": mEnrolledAnimal
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#user_messge").text(data.msg);
                }else {
                    location.href = "${pageContext.request.contextPath}/myDoorkeeperApplication?type=4";
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }


    function queryInOutTimeInfo(){
        var postUrl = "${pageContext.request.contextPath}/queryMyApproval";
        var str = {
            "id": "${param.id}",
            "approvalNoteId": userdt.result.id,
            "approvalStatus": "6"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#operation_status").attr("value","确认提交");
                    $("#operation_status").click(function(){
                        addInOutTime();
                    });
                }else {
                    $("#operation_status").attr("value","确认修改");
                    $("#operation_status").click(function(){
                        updateInOutTime();
                    });

                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });

    }

    function queryApplyInfo(){
        var postUrl = "${pageContext.request.contextPath}/queryApplication";
        var str = {
            "myApproval": {
                "id": "${param.id}",
            },
            "id": "${param.id}",
            "accessStatus": "${param.type}"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#user_messge").text(data.msg);
                }else {
                    initApply(data);
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

    function initApply(data){
        $("#name_college").val(data.result.userReplenish.belongsCollege);

        $("#student_number").val(data.result.teacherStudentNumber);
        $("#user_name").val(data.result.userName);
        $("#user_sex").val(data.result.userSex);
        $("#dormitory_area").val(data.result.dormitoryArea);
        $("#dormitory_no").val(data.result.dormitoryNumber);
        $("#student_type").val(data.result.studentType);
        $("#user_tel").val(data.result.contactNumber);
        $("#start_time").val(data.result.startTime);
        $("#end_time").val(data.result.endTime);
        $("#trip_mode").val(data.result.tripMode);
        $("#destination").val(data.result.destination);
        $("#reasons_school").val(data.result.pursueReason);
        $("#travel_route").val(data.result.travelRoute);


        if (data.result.myApprovalList.length !== 0){
            for (var k = 0; k < data.result.myApprovalList.length; k++){
                if (data.result.myApprovalList[k].userLevel === "3"){
                    $("#leaders_name").val(data.result.myApprovalList[k].nameApproval);
                    $("#leaders_agree_state").val(data.result.myApprovalList[k].approvalResult);
                    $("#leaders_audit_recommen").val(data.result.myApprovalList[k].approvalAdvice);

                }else if (data.result.myApprovalList[k].userLevel === "4"){
                    $("#school_name").val(data.result.myApprovalList[k].nameApproval);
                    $("#school_agree_state").val(data.result.myApprovalList[k].approvalResult);
                    $("#school_audit_recommen").val(data.result.myApprovalList[k].approvalAdvice);

                }else if (data.result.myApprovalList[k].userLevel === "5"){

                    $("#out_time").val(data.result.myApprovalList[k].nameApproval);
                    $("#enrolled_time").val(data.result.myApprovalList[k].approvalResult);
                    $("#enrolled_animal").val(data.result.myApprovalList[k].approvalAdvice);


                    if (data.result.myApprovalList[k].nameApproval != null){
                        $("#out_time").attr("disabled",true);
                    }
                    if (data.result.myApprovalList[k].approvalResult != null){
                        $("#enrolled_time").attr("disabled",true);
                    }
                    if (data.result.myApprovalList[k].approvalAdvice != null){
                        $("#enrolled_animal").attr("readOnly",true);
                        $("#operation_status").hide();
                    }

                }
            }
        }


    }


    function notEditable(){
        $("#name_college").attr("disabled",true);
        $("#student_number").attr("readOnly",true);
        $("#user_name").attr("readOnly",true);
        $("#user_sex").attr("disabled",true);
        $("#user_tel").attr("readOnly",true);
        $("#start_time").attr("disabled",true);
        $("#end_time").attr("disabled",true);
        $("#trip_mode").attr("readOnly",true);
        $("#destination").attr("readOnly",true);
        $("#reasons_school").attr("readOnly",true);
        $("#travel_route").attr("readOnly",true);
    }


    //加载时间控件
    $('.form_datetime').datetimepicker({
        //默认语言
        language: 'zh-CN',
        //默认选择格式
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true,
        todayBtn: true,
        startView: 2,
    });


</script>

</body>
</html>
</span>